package web.servlet.doctor;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import service.DoctorServiceImpl;
import domain.Doctor;

public class FindDoctorByManyConditionServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");

		// 获取表单数据
		String doctorId = request.getParameter("doctorId");
		String doctorName = request.getParameter("doctorName");
		String expertise = request.getParameter("expertise");
		String doctorPhone = request.getParameter("doctorPhone");
		String credentials = request.getParameter("credentials");

		// 调用业务逻辑

		DoctorServiceImpl ds = new DoctorServiceImpl();
		List<Doctor> list = ds.findDoctorByConditions(doctorId, doctorName, expertise, doctorPhone, credentials);
		// 分发转向
		request.setAttribute("doctors", list);// 把list放入request对象中
		request.getRequestDispatcher("/admin/doctor/list.jsp").forward(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request, response);
	}

}
